#ifndef VARIANTINPUT_H
#define VARIANTINPUT_H

#include <QtGui/QWidget>
#include <QtGui/QPushButton>
#include <QtGui/QTableView>
#include <QtGui/QAbstractItemDelegate>
#include "../APnModel-IDE/variantmodel.h"
#include "../APnModel-IDE/typedelegate.h"

class VariantInput : public QWidget
{
	Q_OBJECT

public:
	VariantInput(const QVariant & var = QVariant("http://sites.google.com/site/dunanshan"),
		QWidget * parent = 0, Qt::WindowFlags f = 0);
	~VariantInput();

	QVariant value();
	void setValue(const QVariant& value);

signals:
	void commit();

private slots:
	void addRow();
	void deleteRow();
	void commitData();

	void freshButton();

	void editCollection(const QModelIndex & index);
	void setDelegate();

	//void save();
	//void read();
	//void setTitle();

private:
	QTableView *view;
	VariantModel *model;

	QModelIndex mIndex;

	QPushButton *addButton;
	QPushButton *delButton;

	QAbstractItemDelegate *mDefaultDelegate;
	TypeDelegate *mTypeDelegate;
};

#endif // VARIANTINPUT_H
